<template>
  <div class="prayeradd">
    <b-container>
      <img class="img-fluid mb-3" src="http://www.xinde.org/uploadfile/other/prayer/me.jpg" style="width:100%">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-input name="typeid" type="hidden" value="88"></el-input>
        <el-form-item label="祈祷者：" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="祈祷意向：" prop="typeid">
          <el-input v-model="ruleForm.typeid" value="自由祈祷意向" disabled=""></el-input>
        </el-form-item>
        <el-form-item label="献 花：" prop="huaid">
          <el-radio-group v-model="ruleForm.huaid">
            <el-radio label="1"><img src="/uploadfile/other/prayer/1.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="3"><img src="/uploadfile/other/prayer/3.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="7"><img src="/uploadfile/other/prayer/7.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="8"><img src="/uploadfile/other/prayer/8.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="6"><img src="/uploadfile/other/prayer/6.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="11"><img src="/uploadfile/other/prayer/11.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="10"><img src="/uploadfile/other/prayer/10.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="17"><img src="/uploadfile/other/prayer/17.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="18"><img src="/uploadfile/other/prayer/18.jpg" style="max-height: 60px"></el-radio>
            <el-radio label="19"><img src="/uploadfile/other/prayer/19.jpg" style="max-height: 60px"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="祈祷内容：" prop="content">
          <el-input type="textarea" v-model="ruleForm.content" maxlength="800" rows="8"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </b-container>
    <Footer msg="Welcome to Your Vue.js App" />
  </div>
</template>


<script>
import Vue from 'vue';
import Footer from "@/components/Footer.vue";
import {
  Input,
  InputNumber,
  Radio,
  RadioGroup,
  Button,
  Form,
  FormItem
} from 'element-ui';
Vue.use(Input);
Vue.use(InputNumber);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Button);
Vue.use(Form);
Vue.use(FormItem);
export default {
  name: "prayeradd",
  components: {
    Footer
  },
  data () {
    return {
      ruleForm: {
        name: '',
        huaid: '',
        content: ''
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        // region: [
        //   { required: true, message: '请选择活动区域', trigger: 'change' }
        // ],
        // date1: [
        //   { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        // ],
        // date2: [
        //   { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        // ],
        // huaid: [
        //   { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
        // ],
        huaid: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        content: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm (formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>